from django.http import  HttpResponseRedirect, HttpResponse
from regist.models import Restaurant
from common.json import packIntoJsonData
from common.error import commonResponse
from django.test import TestCase


def home(request):
    
    return HttpResponseRedirect( '/regist/quickRegist/' )


def addrestaurant(request):
    Result = commonResponse()
    
    newres = Restaurant(
                        name = "restaurantname13", 
                        anothername = "anothername9", 
                        tastestyle= 9, 
                        address = "address9", 
                        nearby = "nearby9", 
                        gpsposition_x = 9, 
                        gpsposition_y = 9, 
                        phone1 = 18601612699, 
                        phone2 = 1234567899, 
                        open = 9, 
                        close = 29, 
                        howtogetthere = "howtogetthere9", 
                        administrator = "administrator13",
                        queuestartflag = False,
                        queuenextcallnum = 0,
                        queuenextdistributenum = 0
                        )
       
    if newres is not None:
        newres.save(True)
        Result.result = 0
        
    else:
        Result.result = -1
        
    #self.assertEqual(count + 1, Restaurant.objects.count() )
    return HttpResponse(packIntoJsonData( Result ),mimetype="text/json")
    